function getStatusJsonAjax()
{
	$.ajax({
		type:'post',
		url: getStatusUrl,
		dataType:"json",
		data:{'productId':productId},
		cache: false,
		async: true,
		success: function(value) 
		{  
			if(value && value.success == 1)
			{
				var result = value.info;
				if(result)
				{
					isLogin = result.isLogin;
					userId = result.userId;
					userName = result.userName;
					isCustomerService = result.isCustomerService;
					isBuy = result.isBuy;
					getAvgScore();
					displayScoreCommentAjaxData();
					displayCommentAjaxData();
				}
			}
		}
	});
}

function displayViewedItemsAjax()
{
	$("#recent_view_list").html('');
	
	$.ajax({
		type:'post',
		url:displayViewedItemsAjaxUrl,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value) 
		{  
			if(value != null && value.length > 0)
			{
				var htmlContent = displayViewedItems(value);
    			$("#recent_view_list").append(htmlContent).find('img').lazyLoad({
    				effect:'fadeIn',
    				effectDuration:200,
    				onload : function(){
    					this[0].style.background = 'none';
    				}
    			});
			}
			else
			{
				$("#browse").css('display','none');
			}
		}
	});
}

function displayViewedItems(jsonData)
{
	if(jsonData==undefined || jsonData.length==0)
	{
		return '';
	}
	var dataListContent = '';
	for(var i = 0; i < jsonData.length; i++)
	{
		dataListContent += displayOneViewedItems(jsonData[i]);
	}

	return dataListContent
}

function displayOneViewedItems(oneJsonData)
{
	var htmlContent = "";
	htmlContent = '<li class="clearfix"><input name="selectComparedViewed" type="checkbox" value="##id##" /><a href="##productUrl##" target="_blank" title="##productName##"><img alt="##productName##" src="##loading##" longdesc="##productImage##" width="58" height="58" style="background:url(##loadingSmall##) no-repeat 50% 50%" /></a><a href="##productUrl##" target="_blank" class="name" title="##productName##">##productName##</a><em>¥ ##productPrice##</em></li>';
	htmlContent = htmlContent.replace(/##id##/g,oneJsonData.id);
	htmlContent = htmlContent.replace(/##productName##/g,oneJsonData.productName);
	htmlContent = htmlContent.replace(/##productUrl##/g,oneJsonData.productUrl);
	htmlContent = htmlContent.replace(/##loading##/g,placeUrl);
	htmlContent = htmlContent.replace(/##loadingSmall##/g,loadingSmallUrl);
	htmlContent = htmlContent.replace(/##productImage##/g,oneJsonData.productImage);
	htmlContent = htmlContent.replace(/##productUrl##/g,oneJsonData.productUrl);
	htmlContent = htmlContent.replace(/##productPrice##/g,oneJsonData.productPrice);

	return htmlContent;
}

function addItem2ComparedAjaxM()
{
	var productIds = ""
	$('input[@type=checkbox][name=selectComparedViewed][checked]').each(function(i){
			if(i!=0)
			{
				productIds +=",";
			}
			productIds +=$(this).val();
		});
	addItem2ComparedAjax(productIds);
}

function deleteViewedItemsAjax()
{
	wep.dialog({
		title : '消息提示',
		content : '你确定清空所有浏览记录？',
		onyes : function(){
			$.ajax({
				type:'post',
				url: deleteViewedItemsAjaxUrl,
				dataType:"json",
				cache: false,
				async: true,
				success: function(value) 
				{  
					 $("#browse").hide();
				}
			});
		},
		onno : function(){
			this.hide();
		},
		width : 300,
		lock : true,
		icoBasePath : imagesUrl,
		icon : 'info.gif'
	});
}

function add2Cart(productId, qty, pop, e, offset)
{
	jQuery.ajax({
		type:'post',
		url: add2CartUrl,
		data:'product='+productId+'&qty='+qty,
		dataType:"json",
		cache: false,
		async: true,
		beforeSend:function()
		{
			jQuery("#loading_state_addtocart").show();
		},
		complete:function()
		{
			jQuery("#loading_state_addtocart").hide();
		},
		success: function(value)
		{
			if(value.success==1)
			{
				//此处提交交互，交互完成后，回调以下语句
				jQuery("#cart-total_addtocart").html(value.qty);

				ss = value.subtotal.toString().split(".");
				var intdot = ss[0];
				var fraction = '00';
				if(ss.length>1)
				{
					fraction = ss[1];
				}
				
				jQuery("#cart-subtotal_addtocart_intdot").html(intdot+".");
				jQuery("#cart-subtotal_addtocart_fraction").html(fraction);
				
				pop.css({
					left : e.pageX - offset.left,
					top : e.pageY - offset.top
				})
				.show();
				
				refreshDisplayCart();
			}
			else
			{
				if(value.info=="notlogin")
				{
					showInfoTip('请先登录','info');
					window.location = loginUrl;
				}
				else
				{
					showInfoTip(value.info,'info');
				}
			}
		}
	});
}

function addOneQty()
{
	var pro_count = $("#pro_count").val();
	if(isNaN(parseInt(pro_count)) || parseInt(pro_count)==0)
	{
		pro_count = 1;
	}
	if(pro_count < 99)
	{
		pro_count++;
		$("#pro_count").val(pro_count);
	}
}
function subOneQty()
{
	var pro_count = $("#pro_count").val();
	if(isNaN(parseInt(pro_count)) || parseInt(pro_count)==0)
	{
		pro_count = 1;
	}

	pro_count--;

	if(pro_count==0)
	{
		pro_count=1;
	}
	lastNum = pro_count;
	$("#pro_count").val(pro_count);
}

function changePage(pageV,category)
{
	page = pageV;
	if(category == '1')
	{
		displayCommentAjaxData();
		location.hash = '#promember_reprot';
	}
	if(category == '2')
	{
		displayScoreCommentAjaxData();
		//location.hash = '#proclient_report';
		typeof window.cmtPageChange === 'function' && cmtPageChange.call(null, pageV);
	}
}

//获取平均分
function getAvgScore()
{
	jQuery.ajax({
		type:'post',
		url: getAvgScoreUrl,
		data:{'id':productId},
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			if(value != null && value.success == 1)
			{
				var data = value.info;
				var integer = "0";
				var decimal = ".0";
				var score = data.score;
				var countN = data.countN;
				if(score != null)
				{
					if(score < 10)
					{
						integer = score.substring(0,1);
						decimal = score.substring(1,3);
					}
					else
					{
						integer = score.substring(0,2);
						decimal = '';
					}
				}
				else
				{
					score = 0;
				}
				$("#comment_pro_star").html('<em style="width:'+Math.round(score)*10+'%">'+score+'</em>');
				$("#score_value").html('<strong class="val">'+integer+'<sub>'+decimal+'</sub></strong><strong class="val mask">'+integer+'<sub>'+decimal+'</sub></strong>');
				$("#star_count").html('<strong class="star"><em style="width:'+Math.round(score)*10+'%">'+score+'</em></strong><span class="count">共<em>'+countN+'</em>人评分</span>');
				if(countN != 0)
				{
					$("#pro_star_counter").html('有('+countN+')个评分');
				}
			}
		}
	});
}

function getValidateCode(obj)
{
	var validateCodeUrl = getValidateCodeUrl+'?t='+Math.random();
	obj.value="";
	jQuery("#validate_code_img_id").remove();
	$('<img />').load(function(){
		$(obj).after(this);
	})
	.attr({
		id : "validate_code_img_id",
		src : validateCodeUrl,
		height : 30,
		width : 100
	});
}

function lostFocus(obj){
	if(obj.value==""){
		obj.value="点击获取";
		obj.style.color='#ccc';
	}
	$(obj).next().remove();
}

//会员评论
function displayCommentAjaxData()
{
	var ajaxData = {'page':page,'productId':productId};
	jQuery.ajax({
		type:'post',
		url: getCommentDataJsonUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{  
			displayComment(value);
		}
	});
}

function displayComment(value)
{
	jQuery("#comment_html").html('');
	if(value != null && value.dataList != null && value.dataList.length > 0)
	{
		var data = value.dataList;
		var totalPage = value.pageInfo.totalPage;
		var startPage = value.pageInfo.startPage;
		var endPage = value.pageInfo.endPage;
		var dataCount = value.pageInfo.dataCount;
		var pagerContent = buildSpecialPager(page,totalPage,startPage,endPage,1);
		$("#pager2").html('');
		$("#pager2").html(pagerContent);
		var htmlContent = "";
		for(var i = 0; i < data.length; i++)
		{
			htmlContent +=	'<div class="cmt_item consult_item';
			if(i % 2 != 0)
			{
				htmlContent +=	' even';
			}
			htmlContent += ' ">';
			htmlContent +=	'	<div class="cmt_header">';
			htmlContent +=	'		<a href="http://bbs.weiphone.com/u.php" class="pic"><span class="curr"><img src="http://passport.weiphone.com/ucenter/avatar.php?uid='+value.dataList[i].user_id+'&size=small" height="56" width="56" alt="'+data[i].user_name+'" /></span><i></i></a>';
			htmlContent +=	'		<strong class="name">'+data[i].user_name+'</strong>';
			htmlContent +=	'		<i class="arrow"><b></b></i>';
			htmlContent +=	'	</div>';
			htmlContent +=	'	<div class="cmt_main">';
			htmlContent +=	'		<p data-commentid = "'+data[i].id+'">'+data[i].comment+'</p>';
			htmlContent +=	'		<span class="timer">'+data[i].create_time+'</span>';
			htmlContent +=	'	</div>';
			htmlContent +=	'	<div class="consult_reply">';
			if(data[i].manager_replys != null && data[i].manager_replys.length > 0)
			{
				var manager = data[i].manager_replys;
				for(var j=0; j < manager.length; j++)
				{
					htmlContent +=	'		<div class="cmt_header">';
					htmlContent +=	'			<a href="http://bbs.weiphone.com/u.php" class="pic"><span class="curr"><img src="http://passport.weiphone.com/ucenter/avatar.php?uid='+manager[j].user_id+'&size=small" height="56" width="56" alt="'+manager[j].user_name+'" /></span><i></i></a>';
					htmlContent +=	'			<strong class="name">'+manager[j].user_name+'</strong>';
					htmlContent +=	'			<i class="arrow"><b></b></i>';
					htmlContent +=	'		</div>';
					break;
				}
				htmlContent +=	'		<div class="cmt_main">';
				for(var j=0; j < manager.length; j++)
				{
					htmlContent +=	'			<p>'
					htmlContent +=					manager[j].comment;
					if(isLogin && isCustomerService)
					{
						htmlContent +=					'</br>';
						htmlContent +=					'<a style="color:#c00;" class="del" href="javascript:;" onclick="deleteComment('+manager[j].id+',1);return false;">[ 删除 ]</a>'
					}	
					htmlContent +=  '			</p>';
					htmlContent +=	'			<span class="timer">'+manager[j].create_time+'</span>';
				}
				htmlContent +=	'		</div>';
			}
			htmlContent +=	'	</div>';
			if(isLogin && isCustomerService)
			{
				htmlContent +=	'	<div class="cmt_adm">';
				htmlContent +=	'		<a href="javascript:void(0)" onclick="deleteComment('+data[i].id+',1);return false;" class="del" title="删除"><span>删除</span></a>';
				htmlContent +=	'		<a href="#" class="rep consult_rep" title="回复"><span>回复</span></a>';
				htmlContent +=	'	</div>';
			}
			htmlContent +=	'</div>';
		}
		$("#comment_html").html(htmlContent);
	}
}

//客户评论
function displayScoreCommentAjaxData()
{
	var ajaxData = {'page':page,'orderType':orderType,'productId':productId};
	jQuery.ajax({
		type:'post',
		url : getCustomerCommentDataJsonUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{  
			displayScoreComment(value);
		}
	});
}

function displayScoreComment(value)
{
	var htmlContent = '';
	var data = value.dataList;
	if(data != null && data.length > 0)
	{
		var totalPage = value.pageInfo.totalPage;
		var startPage = value.pageInfo.startPage;
		var endPage = value.pageInfo.endPage;
		var dataCount = value.pageInfo.dataCount;
		var pagerContent = buildSpecialPager(page,totalPage,startPage,endPage,2);
		htmlContent += '<div class="cmt_top"></div>';
		for(var i = 0; i < data.length; i++)
		{
			if(data[i].parent_id == 0)
			{
				htmlContent += '<div class="cmt_item">';
				htmlContent += '	<div class="cmt_item_inner">';
				htmlContent += '		<div class="cmt_header">';
				htmlContent += '			<a href="http://bbs.weiphone.com/u.php" class="pic"><span class="curr"><img src="http://passport.weiphone.com/ucenter/avatar.php?uid='+data[i].user_id+'&size=small" height="56" width="56" alt="'+data[i].user_name+'" /></span><i></i></a>';
				htmlContent += '			<strong class="name">'+data[i].user_name+'</strong>';
				htmlContent += '			<span class="timer">'+data[i].create_time+'</span>';
				if(data[i].is_addcomment == "n")
				{
					if(data[i].score == null)
					{
						data[i].score = 0;
					}
					htmlContent += '			<strong class="star" title="'+data[i].score+'分"><em style="width:'+data[i].score*10+'%">'+data[i].score+'</em></strong>';
				}
				htmlContent += '			<i class="arrow"><b></b></i>';
				htmlContent += '		</div>';
				htmlContent += '		<div class="cmt_main">';
				htmlContent += '			<p>'+data[i].comment+'</p>';
				var q = 1;
				for(var j = 0; j < data.length; j++)
				{
					if(data[j].parent_id == data[i].id && data[j].second_parent_id == 0)
					{
						htmlContent += '		<div class="cmt_reply">';
						htmlContent += '			<i>'+q+'</i>';
						htmlContent += '			<span class="pic"><img src="http://passport.weiphone.com/ucenter/avatar.php?uid='+data[j].user_id+'&size=small" height="37" width="37" alt="'+data[j].user_name+'" /></span>';
						htmlContent += '			<span class="name">'+data[j].user_name+':</span>';
						htmlContent += '			<span class="timer">'+data[j].create_time+'</span>';
						htmlContent += '			<div class="main" data-commentid="'+data[i].id+'" data-parentId="'+data[j].id+'">';
						htmlContent += '				<p>'+data[j].comment+'<p>';
						htmlContent += '			</div>';
						htmlContent += '			<div class="cmt_adm">';
						if(isLogin && isCustomerService)
						{
							htmlContent += '			<a href="javascript:;" class="rep" title="客服回复"><span>回复</span></a>';
							htmlContent += '			<a href="javascript:;" onclick="deleteComment('+data[j].id+',2);return false;" class="del" title="删除"><span>删除</span></a>';
						}
						htmlContent += '			</div>';
						htmlContent += '		</div>';
						q++;
						if(data[j].manager_replys != null && data[j].manager_replys.length > 0)
						{
							var replys = data[j].manager_replys;
							for(var k = 0; k < replys.length; k++)
							{
								htmlContent += '		<div class="cmt_reply">';
								htmlContent += '			<i>'+q+'</i>';
								htmlContent += '			<span class="pic"><img src="http://passport.weiphone.com/ucenter/avatar.php?uid='+replys[k].user_id+'&size=small" height="37" width="37" alt="'+replys[k].user_name+'" /></span>';
								htmlContent += '			<span class="name">'+replys[k].user_name+':</span>';
								htmlContent += '			<span class="timer">'+replys[k].create_time+'</span>';
								htmlContent += '			<div class="main">';
								htmlContent += '  				<blockquote><span class="name">@'+data[j].user_name+'</span>'+data[j].comment+'</blockquote>';
								htmlContent += '				<p>'+replys[k].comment+'<p>';
								htmlContent += '			</div>';
								htmlContent += '		</div>';
								q++;
							}
						}
					}
				}
				htmlContent += '		</div>';
				htmlContent += '		<div class="cmt_btns">';
				htmlContent += '			<a id="useful_'+data[i].id+'" href="javascript:;" class="agree" onclick="commentUseful('+data[i].id+',1);return false;" useful ="'+data[i].useful+'"><span>支持(<em>'+data[i].useful+'</em>)</span></a>';
				htmlContent += '			<a id="nouse_'+data[i].id+'" href="javascript:;" class="oppose" onclick="commentUseful('+data[i].id+',0);return false;" nouse = "'+data[i].nouse+'"><span>反对(<em>'+data[i].nouse+'</em>)</span></a>';
				htmlContent += '		</div>';
				if(isLogin && isCustomerService)
				{
					htmlContent += '		<div class="cmt_adm">';
					htmlContent += '			<a href="javascript:;" onclick="deleteComment('+data[i].id+',2);return false;" class="del" title="删除"><span>删除</span></a>';
					htmlContent += '		</div>';
				}
				htmlContent += '		<div id="replyCustomerComment_'+data[i].id+'" class="cmt_inpts cmt_inputs_min">';
				htmlContent += '			<form action="">';
				htmlContent += '			<div class="txt_panel">';
				htmlContent += '				<div class="txt"><input type="hidden" id="reply_hidden_'+data[i].id+'" name="reply_hidden_'+data[i].id+'" value="0"><label for="reply_score_content_'+data[i].id+'">在此回复...</label><textarea id="reply_score_content_'+data[i].id+'"></textarea></div>';
				htmlContent += '			</div>';
				htmlContent += '			<div class="ext_panel">';
				htmlContent += '				<a href="javascript:;" onclick="replyCustomerComment(this,'+data[i].id+');" class="btn send"><span>发表</span></a>';
				htmlContent += '				<a href="javascript:;" onclick="cancelReply('+data[i].id+')" class="btn cancel"><span>取消</span></a>';
				htmlContent += '				<span class="chk_code">';
				htmlContent += '					<label for="reply_score_code_'+data[i].id+'">验证码：</label>';
				htmlContent += '					<input type="text" id="reply_score_code_'+data[i].id+'" value="点击获取" onfocus="getValidateCode(this)" onblur="lostFocus(this)" style="color: rgb(204, 204, 204)"/>';
				htmlContent += '				</span>';
				htmlContent += '			</div>';
				htmlContent += '		</form>';
				htmlContent += '	</div>';
				htmlContent += '</div>';
				htmlContent += '</div>';
			}
		}
		htmlContent += '<div class="cmt_bottom"></div>';
		htmlContent += '<div class="cmt_pager">';
		htmlContent += 	pagerContent;
		htmlContent += '</div>';
		htmlContent += '</div>';
		htmlContent += '</div>';
	}
	var id = "pro_cmt_all";
	if(orderType == "high")
	{
		id = "pro_cmt_new";
	}
	if(orderType == "low")
	{
		id = "pro_cmt_hot";
	}
	$("#"+id).html('');
	$("#"+id).html(htmlContent);
}

function customer_reply(id,pid,name)
{
	$("#replyCustomerComment_"+pid).removeClass('cmt_inputs_min');
	$("#reply_hidden_"+pid).val(id);
	$("#reply_score_content_"+pid).val("@"+name+" ").focus();
}

//save会员评论
function saveComment()
{
	var content = $("#comment_content").val();
	if(content)
	{
		content = content.replace(/^\s*/, '');
	}
	if(content == null || content == "")
	{
		showInfoTip('内容不能为空！','info');
		return;
	}
	var commentCode = $("#commentCode").val();
	if(commentCode == null || commentCode == "")
	{
		showInfoTip('请输入验证码！','info');
		return;
	}
	jQuery.ajax({
		type:'post',
		url: saveCommentUrl,
		data:{'content':content,'commentCode':commentCode,'id':productId},
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{  
			if(value.success == "1")
			{
				$("#comment_content").val('');
				$("#commentCode").val('点击获取');
				$("#comment_div").addClass('cmt_inputs_min');
				page = 1;
				displayCommentAjaxData();
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}

function cancelReply(id)
{
	$("#reply_score_content_"+id).val('');
	$("#replyCustomerComment_"+id).addClass('cmt_inputs_min');
}

function cancelComment()
{
	$("#comment_content").val('');
	$("#comment_div").addClass('cmt_inputs_min');
}

//save客户评论
function saveCustomerComment()
{
	var content = $("#newscore_comment").val();
	if(content)
	{
		content.replace(/^\s*/, '');
	}
	if(content == null || content == "")
	{
		showInfoTip('评论不能为空！','info');
		return;
	}
	var code = $("#comm12_code").val();
	if(code=="" || code=="点击获取")
	{
		showInfoTip('请输入验证码！','info');
		return;
	}
	var anonymity = 0;
	if($("#anon").attr("checked")==true)
	{
		anonymity = 1;
	}
	jQuery.ajax({
		type:'post',
		url : saveCustomerCommentUrl,
		data:{'content':content,'code':code,'anonymity':anonymity,'id':productId},
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{  
			if(value.success == "1")
			{
				page = 1;
				displayScoreCommentAjaxData();
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}

function deleteComment(id,category)
{
	var ajaxData = {'id':id,'category':category};
	jQuery.ajax({
		type:'post',
		url: deleteCommentUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{  
			if(value.success == 1)
			{
				if(category == 1)
				{
					displayCommentAjaxData();
				}
				if(category == 2 || category == 3)
				{
					displayScoreCommentAjaxData();
				}
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});	
}

//回复客户评论
function replyCustomerComment(obj,id)
{
	var content = $("#reply_score_content_"+id).val();
	var replyCode = $("#reply_score_code_"+id).val();
	if(content)
	{
		content = content.replace(/^\s*/, '')
	}
	if(content=="")
	{
		showInfoTip('回复内容不能为空！','info');
		return;
	}
	if(replyCode=="" || replyCode=="点击获取")
	{
		showInfoTip('请输入验证码！','info');
		return;
	}
	cancelReply(id);
	jQuery.ajax({
		type:'post',
		url: replyScoreCommentAjaxUrl,
		data:{"productId":productId,"code":replyCode,"content":content,"parentId":id,"isCustomerService":isCustomerService},
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			if(value.success==1)
			{
				displayScoreCommentAjaxData();
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}


//有用没用
function commentUseful(id,category)
{
	$("#useful_"+id).replaceWith('<a id="useful_'+id+'" href="javascript:;" class="agree disabled"><span>支持(<em>'+$("#useful_"+id).children().children().html()+'</em>)</span></a>');
	$("#nouse_"+id).replaceWith('<a id="nouse_'+id+'" href="javascript:;" class="oppose disabled"><span>反对(<em>'+$("#nouse_"+id).children().children().html()+'</em>)</span></a>');
	jQuery.ajax({
		type:'post',
		url: commentUsefulUrl,
		data:{"id":id,"category":category},
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			if(value.success == 1)
			{
				if(category == '1')
				{
					$("#useful_"+id).replaceWith('<a id="useful_'+id+'" href="javascript:;" class="agree disabled"><span>支持(<em>'+value.info+'</em>)</span></a>');
					$("#nouse_"+id).replaceWith('<a id="nouse_'+id+'" href="javascript:;" class="oppose disabled"><span>反对(<em>'+$("#nouse_"+id).children().children().html()+'</em>)</span></a>');
				}
				if(category == '0')
				{
					$("#useful_"+id).replaceWith('<a id="useful_'+id+'" href="javascript:;" class="agree disabled"><span>支持(<em>'+$("#useful_"+id).children().children().html()+'</em>)</span></a>');
					$("#nouse_"+id).replaceWith('<a id="nouse_'+id+'" href="javascript:;" class="oppose disabled"><span>反对(<em>'+value.info+'</em>)</span></a>');
				}
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});	
}

//支持评论
function supportComment(commentId,score)
{
	var ajaxData = {"commentId":commentId,"score":score};
	jQuery.ajax({
		type:'post',
		url: supportUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			if(value.success==1)
			{
				if(score == 'score')
				{
					$("#score_comment_agree_"+commentId).replaceWith('<a id="score_comment_agree_'+commentId+'" href="javascript:;" class="report_agree" style="cursor:default">支持('+value.info+')</a>');
					$("#score_comment_oppose_"+commentId).replaceWith('<a id="score_comment_oppose_'+commentId+'" href="javascript:;" class="report_oppose" style="cursor:default">'+jQuery("#score_comment_oppose_"+commentId).html()+'</a>');
				}
				else
				{
					$("#comment_agree_"+commentId).replaceWith('<span class="report_agree">支持('+value.info+')</span>');
					$("#comment_oppose_"+commentId).replaceWith('<span class="report_oppose">'+jQuery("#comment_oppose_"+commentId).html()+'</span>');
				}
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}

//反对评论
function opposeComment(commentId,score)
{
	var ajaxData = {"commentId":commentId,"score":score};
	jQuery.ajax({
		type:'post',
		url: opposeUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			if(value.success==1)
			{
				if(score == 'score')
				{
					$("#score_comment_agree_"+commentId).replaceWith('<a id="score_comment_agree_'+commentId+'" href="javascript:;" class="report_agree" style="cursor:default">'+jQuery("#score_comment_agree_"+commentId).html()+'</a>');
					$("#score_comment_oppose_"+commentId).replaceWith('<a id="score_comment_oppose_'+commentId+'" href="javascript:;" class="report_oppose" style="cursor:default">反对('+value.info+')</a>');
				}
				else
				{
					$("#comment_agree_"+commentId).replaceWith('<span class="report_agree">'+jQuery("#comment_agree_"+commentId).html()+'</span>');
					$("#comment_oppose_"+commentId).replaceWith('<span class="report_oppose">反对('+value.info+')</span>');
				}
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}

function addFavorite(productId,obj)
{
	var ajaxData = {"product_id":productId};
	jQuery.ajax({
		type:'post',
		url: addFavoriteUrl,
		data:ajaxData,
		dataType:"json",
		cache: false,
		async: true,
		success: function(value)
		{
			var icon = "";
			if(value.success=="1")
			{
				$(obj).replaceWith('<span class="pro_atten">已收藏</span>');
				showInfoTip(value.info+'，点击<a href="'+addFavoriteIndexUrl+'" target="_blank" style="color:#09f; font-weight:bold; text-decoration:underline">查看我的收藏</a>','success');
			}
			else
			{
				showInfoTip(value.info,'info');
			}
		}
	});
}

function checkQty(obj)
{
	var qty = $(obj).val();
	if(!/[^0-9-]+/.test(qty))
	{
		qty = parseInt(qty);
		if(qty < 1)
		{
			$(obj).val(lastNum);
		}else
		{
			lastNum = qty;
		}
	}
	else
	{
		$(obj).val(lastNum);
	}
}

function refreshDisplayCrosssellItems(){
	$.ajax({
		type:'post',
		url: getCrossellItemsUrl,
		dataType:"json",
		data:{"productId":productId},
		cache: false,
		async: true,
		success: function(value){
			if(value.success=="1"){
				displayCrosssellItemsDataListContent(value.info.crosssellItems);
			}else{
				wep.dialog({
					   title : '消息',
					   content : value.info,
					   onyes : function(){
							this.close();
					   },
					   width : 200,
					   lock : true
				});
			}
		}
	});
}

function displayCrosssellItemsDataListContent(jsonData){
	var dataListContent = '';
	for(var i = 0; i < jsonData.length; i++){
		dataListContent += displayCrosssellOneRecord(jsonData[i],i);
	}
	if(dataListContent == '')
	{
		$("#guess_love").hide();
	}
	else
	{
		$("#guess_love").show();
		$("#guess_love_items").append(dataListContent).find('img').lazyLoad({
			effect:'fadeIn',
			effectDuration:200,
			onload : function(){
				this[0].style.background = 'none';
			}
		});
	}
}

function displayCrosssellOneRecord(oneJsonData,i){
	var htmlContent = '';
	
	htmlContent += '<li class="clearfix">';
	htmlContent += '<a href="'+oneJsonData.url+'" target="_blank">';
	htmlContent += '<img src="'+placeUrl+'" longdesc="'+oneJsonData.imgsrc+'" width="80" height="80" style="background:url('+loadingSmallUrl+') no-repeat 50% 50%" />';
	htmlContent += '</a>';
	htmlContent += '<a href="'+oneJsonData.url+'" target="_blank" class="name" title="'+oneJsonData.title+'">'+oneJsonData.title+'</a>';
	htmlContent += '<em>&yen;'+oneJsonData.price+'</em>';
	htmlContent += '</li>';
	
	return htmlContent;
}